﻿{extend name="layout/base" /}

{block name="meta"}
{__block__}
<style>
  .lfloat{float:left}
  .rfloat{float:right}
  .shopstr-name{height:32px;line-height:32px}
  .shopstr-name .name{float:left;font-size:18px;color:#2e2e2e;font-weight:700;width:170px;height:30px;display:block;overflow:hidden}
  .shopstr-name .name:hover{color:#f53e28}
  .shopstr-pr{float:left;width:100%;margin-top:7px;color:#807f7f}
  .shopstr-pr .company{text-decoration:underline;color:#57c4f5}
  .shopstr-pr .company:hover{color:#31b0e9}

</style>
{/block}
{block name="body"}
<body class="wishlist_page">
{/block}

{block name="main"}
  <!-- Breadcrumbs -->
  <div class="breadcrumbs">
    <div class="container">
      <div class="row">
        <div class="col-xs-12">
          <ul>
            <li class="home"> <a title="{:__('Home')}" href="{:addon_url('mall')}">{:__('Home')}</a><span>&raquo;</span></li>
            <li><strong>{:__('Wishlist')}</strong></li>
          </ul>
        </div>
      </div>
    </div>
  </div>
  <!-- Breadcrumbs End --> 
  <!-- Main Container -->
  <section class="main-container col2-right-layout">
    <div class="main container">
      <div class="row">
        <div class="col-main col-sm-12 col-xs-12">
          <div class="my-account">
            <div class="page-title">
              <h2>{:__('Wishlist')}</h2>
            </div>
            <div class="wishlist-item table-responsive">
              <table class="col-md-12">
                <thead>
                  <tr>
                    <th class="th-delate">{:__('Remove')}</th>
                    <th class="th-product">{:__('Image')}</th>
                    <th class="th-details">{:__('Goodsname')}</th>
                    <th class="th-price">{:__('Shopprice')}</th>
                    <th class="th-price">{:__('Name')}</th>
                    <th class="th-total th-add-to-cart">{:__('Add to Cart')}</th>
                  </tr>
                </thead>
                <tbody id="goods-tbody">
                </tbody>
              </table>
              <a href="javascript:allAddCart()" class="all-cart">{:__('All').__('Add to cart')}</a> </div>
          </div>
        </div>
      </div>
    </div>
  </section>
<!-- 愿望单模板 -->
<script id="listtpl" type="text/html">
  <%if(list && list.length>0){%>
    <%var allgoodsid="";%>
    <%for(var i=0; i < list.length; i++){%>
      <%allgoodsid = allgoodsid + list[i].goods_id + ',';%>
      <tr>
        <td class="th-delate"><a href="<%='javascript:removeWishlist(this,\'goods\','+list[i].goods_id+','+list[i].id+');'%>">X</a></td>
        <td class="th-product"><a href="<%='/addons/mall/goods/detail?ids='+list[i].goods_id%>"><img src="__MALLCDN__<%=list[i].goodsimg%>" alt="cart"></a></td>
        <td class="th-details"><h2><a href="<%='/addons/mall/goods/detail?ids='+list[i].goods_id%>"><%=list[i].goodsname%></a></h2></td>
        <td class="price"><%=list[i].shopprice%></td>
        <td class="th-details"><a href="<%='/addons/mall/shop/detail?ids='+list[i].shop_id%>"><%=list[i].name%></a></td>
        <td class="td-add-to-cart"><a href="<%='javascript:addCart('+list[i].goods_id+');'%>">{:__('Add to Cart')}</a></td>
      </tr>
    <%}%>
    <input type="hidden" id="c-allgoodsid" name="allgoodsid" value="<%=allgoodsid.substr(0,allgoodsid.length-1)%>">
  <%}else{%>
  <tr>
    <td colspan="6">没有记录！</td>
  </tr>
  <%}%>
</script>


{/block}

{block name="js"}
{__block__}
<script type="text/javascript">
    removeWishlist = function(obj,type,id,fId){
        $.ajax({
            url: '/addons/mall/favorite/cancel',
            type: 'post',
            dataType: 'json',
            data: {id:fId,type:type,},
            success: function (ret) {
                if(ret.code){
                    if(ret.msg) Toastr.success(ret.msg);
                    $.ajax({
                        url: '/addons/mall/favorite/wishlist',
                        type: 'post',
                        dataType: 'json',
                        success: function (ret) {
                            $('#goods-tbody').html(Template("listtpl",ret.data));
                            return false;
                        }
                    });
                }else{
                    if(ret.msg) Toastr.error(ret.msg);
                }
            },
        });
    }

    allAddCart = function(){
        if($("#c-allgoodsid").val()!="") {
            allgoodsids = $("#c-allgoodsid").val().split(",");
            $.each(allgoodsids, function (i, v) {
                addCart(v);
            });
        }
    }
</script>

{/block}
